<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
	<title>模板标签</title>
	<style type="text/css">
	
	ul {
		list-style: none;
		margin: 10px 0;
		border: 1px dotted #aaa;
	}

	li{
		widows: 300px;
		padding: 5px 0;
	}

    </style>
</head>
<body>
	<div class="container">
		<h1>模板标签</h1>
		<div id="box">
			
		</div>
	</div>
<script src="https://cdn.staticfile.org/jquery/3.2.0/jquery.js"></script>
<script type="text/javascript">
// 将小数转为整数进行计算后，再转为小数也可以解决精度问题
Number.prototype.add = function (num) {
	//取两个数值中小数位最大的
  let n1 = !Number.isInteger(+this) ? this.toString().split('.')[1].length : 0
  let n2 = !Number.isInteger(num) ? num.toString().split('.')[1].length : 0
  
  //得到10的N次幂
  let m = Math.pow(10, Math.max(n1, n2))

  return (this * m + num * m) / m
}



console.log((0.1).add(0.2))

console.log(3 + 0.2, 0.1 + 0.2)

console.log('-----------------------\n')
console.log(Math.pow(10,1))
console.log(Math.pow(10,0))
console.log(Math.pow(10,-1))

console.log((3).toString().split('.'))


</script>
</body>
</html>

